package com.fullertontech.framework.jdbc;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
@Configuration
public class TransactionManagerConfig {
	
	@Bean
	public DataSourceTransactionManager productDataSourceTransactionManager(DataSource dataSource) {
		DataSourceTransactionManager dataSourceTransactionManager=new DataSourceTransactionManager();
		dataSourceTransactionManager.setDataSource(dataSource);
		return dataSourceTransactionManager;
	}
	@Bean
	public TransactionTemplate productTransactionTemplate(DataSourceTransactionManager dataSourceTransactionManager) {
		TransactionTemplate transactionTemplate=new TransactionTemplate();
		transactionTemplate.setTransactionManager(dataSourceTransactionManager);
		return transactionTemplate;
	}
}
